package hmvictor.jpql.nodes;

import hmvictor.jpql.JarExplorerTopComponent;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.openide.windows.WindowManager;

/**
 *
 * @author Victor
 */
public class AddJpaJarAction extends AbstractAction {

    public AddJpaJarAction() {
        super("Add JPA Jar");
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileFilter(new FileNameExtensionFilter("Jar file", "jar"));
        if (fileChooser.showOpenDialog(WindowManager.getDefault().getMainWindow()) == JFileChooser.APPROVE_OPTION) {
            JarExplorerTopComponent c = (JarExplorerTopComponent) WindowManager.getDefault().findTopComponent("JarExplorerTopComponent");
            c.addJpaJar(fileChooser.getSelectedFile());
        }
    }

}
